package cn.iocoder.yudao.module.vlog.report.controller.app;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.vlog.report.service.VLogReportService;
import cn.iocoder.yudao.module.vlog.report.vo.AppVLogReportCreateReqVO;
import cn.iocoder.yudao.module.vlog.report.vo.AppVLogReportPageReqVO;
import cn.iocoder.yudao.module.vlog.report.vo.AppVLogReportRespVO;
import cn.iocoder.yudao.module.vlog.report.vo.VLogReportRespVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;

@Tag(name = "用户 App - 视频举报")
@RestController
@RequestMapping("/vlog/report")
@Validated
public class AppVLogReportController {

    @Resource
    private VLogReportService reportService;

    @GetMapping("/create")
    @Operation(summary = "视频/视频评论举报")
    public CommonResult<Long> createReport(@Valid AppVLogReportCreateReqVO reqVO) {
        Long id = reportService.createReport(getLoginUserId(), reqVO);
        return success(id);
    }

    @GetMapping("/my-page")
    @Operation(summary = "获得我的举报分页")
    public CommonResult<PageResult<AppVLogReportRespVO>> getReportPage(@Valid AppVLogReportPageReqVO pageReqVO) {
        PageResult<VLogReportRespVO> pageResult = reportService.getReportPage(getLoginUserId(), pageReqVO);
        return success(BeanUtils.toBean(pageResult, AppVLogReportRespVO.class));
    }


}
